package polestar.Feature;

import java.util.ArrayList;

/**
 * @description:组合各种不同规则，使用规则数量最大的一个规则。胜率？还是当前数量？
 *
 * @author: 张德长 dechang.zhang@ucarinc.com
 * @date: 18:01:59 2018/11/23
 * @version:2.0
 */
public class Rule {
    //连龙
    public static int getSameNumWithoutEqual(ArrayList list) {
        if (list.size() < 1) {
            return 0;
        }
        int theSameNum = 0;
        int size = list.size() - 1;
        String tmp = (String) list.get(list.size() - 1);
        for (int i = size; i > -1; i--) {
            String obj = (String) list.get(i);
            if ("和".equals(obj)) {
                continue;
            }
            if (tmp.equals(obj)) {
                theSameNum++;
            } else {
                break;
            }
        }
        return theSameNum;
    }
    //跳龙
    public static int getDifferentNumWithoutEqual(ArrayList list) {
        if (list.size() < 1) {
            return 0;
        }
        int differnrtNum = 0;
        int size = list.size() - 1;
        String tmp = (String) list.get(list.size() - 1);
        for (int i = size - 1; i > -1; i--) {
            String obj = (String) list.get(i);
            if ("和".equals(obj)) {
                continue;
            }
            if (!tmp.equals(obj)) {
                tmp = obj;
                differnrtNum++;
            } else {
                break;
            }
        }
        return differnrtNum;
    }
}
